<?php
	class loaivanbandb
	{
		public function Add($TenLoaiVanBan, $MoTa)
		{
			$sql = "INSERT INTO `tbl_loaivanban`(`TenLoaiVanBan`, `MoTa`) VALUES('$TenLoaiVanBan', '$MoTa')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaLoaiVanBan)
		{
			$sql = "DELETE FROM `tbl_loaivanban` WHERE MaLoaiVanBan = $MaLoaiVanBan ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaLoaiVanBan, $TenLoaiVanBan, $MoTa)
		{
			$sql = "UPDATE `tbl_loaivanban` 
					SET `TenLoaiVanBan`= '$TenLoaiVanBan', 
						`MoTa`='$MoTa'
					WHERE `MaLoaiVanBan`=$MaLoaiVanBan";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function GetList($MaLoaiVanBan, $TenLoaiVanBan, $MoTa)
		{
			$sql = "SELECT * FROM `tbl_loaivanban` WHERE 1 ";
			if($MaLoaiVanBan != 0)
				$sql .= " AND MaLoaiVanBan = $MaLoaiVanBan ";
			
			if($TenLoaiVanBan != "")
				$sql .= " AND TenLoaiVanBan LIKE '%$TenLoaiVanBan%' ";
			
			if($MoTa != "")
				$sql .= " AND MoTa LIKE '%$MoTa%'";
				
			
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>